package com.ceba.test.modules.admin.service;

import java.util.List;
import java.util.Map;

import abc.data.DataTable;
import com.ceba.base.helper.DBJSONHelper;
import com.ceba.base.helper.LoggerHelper;
import com.ceba.test.base.configs.CebaPathUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ceba.base.web.service.IBaseService;;
import com.ceba.test.modules.admin.dao.InterfaceSignDao;
import com.ceba.test.modules.admin.entity.CustomResource;
import com.ceba.test.modules.admin.entity.FTPObject;
import com.ceba.test.modules.admin.entity.ISign;
import com.ceba.test.modules.admin.entity.QfRule;



public class InterfaceSignService extends IBaseService{

	static Logger logger = LoggerFactory.getLogger(InterfaceSignService.class);
	
	private InterfaceSignDao interfaceSignDao ;
	
	
	public InterfaceSignDao getInterfaceSignDao() {
		return interfaceSignDao;
	}

	public void setInterfaceSignDao(InterfaceSignDao interfaceSignDao) {
		this.interfaceSignDao = interfaceSignDao;
	}
	
	
	

	public boolean deleteFtpSetting(String id) throws Exception{
		return interfaceSignDao.deleteFtpSetting(id);
	}

	/**
	 * 增加ftp配置
	 * @param ftp
	 * @return
	 */
	public boolean addFtp(FTPObject ftp) throws Exception{
		return interfaceSignDao.addFtp(ftp);
	}

	/**
	 * 更新ftp配置
	 * @param ftp
	 * @return
	 */
	public boolean updateFtp(FTPObject ftp) throws Exception{
		return interfaceSignDao.updateFtp(ftp);
	}

	public JSONObject getFTPListSql(String orderBy, String key, Map<String, Object> dic) throws Exception{
		return interfaceSignDao.getFTPListSql(orderBy,key,dic);
	}

	/**
	 * 增加一条签名规则：key模式
	 * @param iSign
	 * @return
	 */
	public boolean addIsign(ISign iSign) throws Exception{
		return interfaceSignDao.addIsignThree(iSign);
	}
	
	
	/**
	 *
	 * @return
	 */
	public boolean addCusResouse(CustomResource cusrule) throws Exception{
		return interfaceSignDao.addCusResouse(cusrule);
	}
	
	public boolean addQiFengRule(QfRule cusrule) throws Exception{
		return interfaceSignDao.addQiFengRule(cusrule);
	}
	
	public boolean queryQiFengRuelByName(String name){
		return interfaceSignDao.queryQiFengRuelByName(name);
	}
	
	public boolean updateCusResouse(CustomResource cusrule) throws Exception{
		return interfaceSignDao.updateCusResouse(cusrule);
	}
	
	public boolean updateQiFengRule(QfRule cusrule) throws Exception{
		return interfaceSignDao.updateQiFengRule(cusrule);
	}

	public boolean queryQifengByNameAndId(String id,String name){
		return interfaceSignDao.queryQifengByNameAndId(id,name);
	}

	
	public CustomResource getByIdCusResouse(String cusruleId)  throws Exception{
		return interfaceSignDao.getByIdCusResouse(cusruleId);
	}
	
	public QfRule getQiFengRuleById(String cusruleId)  throws Exception{
		return interfaceSignDao.getQiFengRuleById(cusruleId);
	}

	/**
	 * 获取骑缝章授权列表
	 */
	public  DataTable getUserDigitalStampPicList(String userId) throws Exception{
		DataTable dtQiPic = interfaceSignDao.getUserDigitalStampPicList(userId);
		return dtQiPic;
	}



	/**
	 * 更新一条签名规则：key模式下
	 * @param iSign
	 * @return
	 */
	public boolean updateISign(ISign iSign) throws Exception{
		return interfaceSignDao.updateIsign1(iSign);
	}

	/**
	 * 服务器模式下
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public ISign getInterfaceSignById(String id) throws Exception {
		return interfaceSignDao.getInterfaceSignById1(id);
		
	}
	
	public boolean deleteISign(String id) throws Exception{
		return interfaceSignDao.deleteIsign(id);
	}
	
	public boolean deleteIsCus(String id) throws Exception{
		return interfaceSignDao.deleteIsCus(id);
	}
	
	public boolean deleteqiFengRule(String id) throws Exception{
		return interfaceSignDao.deleteqiFengRule(id);
	}
	
	public String getCusRulePath(String ruleId){
		return interfaceSignDao.getCusRulePath(ruleId);
	}
	
	
	public JSONObject getInterfaceSignListSql(String key, String orderBy, Map<String, Object> dic) throws Exception{
		try {
			return interfaceSignDao.getInterfaceSignListSql1(key, orderBy, dic);
		} catch (Exception e) {
			LoggerHelper.error(logger, e, "");
			return DBJSONHelper.getEmptyDBJSON();
		}
	}
	
	//ruleType;//0-表示上传配置文件配置规则（比如佛山计量） 1-表示骑缝章规则配置   默认为0
	public JSONObject getCusfaceListSql(String key,String orderBy, Map<String,Object> dic) {
		try {
			return interfaceSignDao.getCusfaceListSql(key, orderBy,dic);
		} catch (Exception e) {
			LoggerHelper.error(logger, e, "");
			return DBJSONHelper.getEmptyDBJSON();
		}
	}

	public JSONObject getCusfaceListSqlOne(String key,String orderBy, Map<String,Object> dic) {
		try {
			return interfaceSignDao.getCusfaceListSqlOne(key, orderBy,dic);
		} catch (Exception e) {
			LoggerHelper.error(logger, e, "");
			return DBJSONHelper.getEmptyDBJSON();
		}
	}

	public JSONObject queryQifengAu(String userId,Map<String, Object> dic) {
		try {
			return interfaceSignDao.queryQifengAu(userId, dic);
		} catch (Exception e) {
			LoggerHelper.error(logger, e, "");
			return DBJSONHelper.getEmptyDBJSON();
		}
	}

	public List<QfRule> getCusfaceListSqlUserId(String userId) throws Exception{
		return interfaceSignDao.getCusfaceListSqlUserId(userId);
	}

	public long queryQifengAuTotal(String userId,Map<String, Object> dic) throws Exception{
		return interfaceSignDao.queryQifengAuTotal(userId,dic);
	}

	public List<QfRule> getCusfaceListSqlOne(String orderBy, String key){
		try{
			return interfaceSignDao.getCusfaceListSqlOne(key, orderBy);
		}catch (Exception e){
			LoggerHelper.error(logger, e, "");
			return null;
		}

	}

	public JSONObject getICusRule(String orderBy, String key,Map<String, Object> dic) {
		try {
			return interfaceSignDao.getICusRule(key, orderBy, dic);
		} catch (Exception e) {
			LoggerHelper.error(logger, e, "");
			return DBJSONHelper.getEmptyDBJSON();
		}
	}
	
	
	public List<CustomResource> getQfRule() throws Exception{
		return interfaceSignDao.getQfRule();
	}
	
	public boolean getICusRuleByName(String name) throws Exception{
		return interfaceSignDao.getICusRuleByName(name);
	}
	
	public FTPObject getFTPObjectById(String id) {
		return interfaceSignDao.getFTPObjectById(id);
		
	}
	
}
